FROM debian:jessie

MAINTAINER lijf <lijf@zts.com.cn>

USER root

#install openssh-server
RUN apt-get update && apt-get install -y wget  curl openssh-server

RUN apt-get install  -y apt-transport-https ca-certificates gnupg2
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
	
#get jdk
RUN wget --header "Cookie: oraclelicense=accept-securebackup-cookie" \
         --no-verbose -O /tmp/jdk-8u66-linux-x64.tar.gz \
             http://download.oracle.com/otn-pub/java/jdk/8u66-b17/jdk-8u66-linux-x64.tar.gz

	 
# install jdk
RUN tar xzf /tmp/jdk-8u66-linux-x64.tar.gz -C /opt/ && mv /opt/jdk1.8.0_*  /opt/jdk1.8
RUN update-alternatives --install /usr/bin/java java /opt/jdk1.8/bin/java 100
RUN update-alternatives --install /usr/bin/javac javac /opt/jdk1.8/bin/javac 100
RUN rm -f  /tmp/jdk-8u66-linux-x64.tar.gz
ENV JAVA_HOME /opt/jdk1.8

#install unzip
RUN apt-get install -y unzip

#install jq
RUN apt-get install -y jq 

# install groovy
RUN wget  -q --no-check-certificate https://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.7.zip   -O /tmp/apache-groovy-binary-2.4.7.zip 
RUN unzip /tmp/apache-groovy-binary-*.zip -d /opt
RUN ln -s /opt/groovy-* /opt/groovy
RUN ln -s /opt/groovy/bin/groovy /usr/local/bin
RUN rm -f  /tmp/apache-groovy-binary-*.zip
ENV GROOVY_HOME /opt/groovy
	
RUN mkdir /var/run/sshd

RUN rm -rf /var/lib/apt/lists/*

EXPOSE 22 

#change the password of root
#ARG rootpasswd=123456
#RUN echo "root:$rootpasswd"|chpasswd

# Add user jenkins to the image
RUN adduser --quiet jenkins

# Set password for the jenkins user (you may want to alter this).
RUN echo "jenkins:jenkins" | chpasswd

ENV HOME /home/jenkins

RUN chown -R jenkins:jenkins $HOME

# private key
RUN mkdir $HOME/.ssh
RUN chown -R jenkins:jenkins $HOME/.ssh


ENTRYPOINT /usr/sbin/sshd -D 

